package daoImpl;

import dao.AccountDao;
import javaBean.Account;
import util.JdbcUtil;

import java.util.ArrayList;

public class AccountDaoImpl implements AccountDao {
    @Override
    public int insert(Account test){
        String sql = "insert into account (id,name,money) values(?,?,?)" ;
        return JdbcUtil.DML(sql,test.getId(),test.getName(),test.getMoney());
    }

    @Override
    public int update(int id,int money){
        String sql = "update account set money = ? where id = ?";
        return JdbcUtil.DML(sql,money,id);
    }

    @Override
    public int delete(int id){
        String sql = "delete from account where id = ?";
        return JdbcUtil.DML(sql,id);
    }

    @Override
    public ArrayList<Account> selectAll(){
        String sql = "select * from account";
        return JdbcUtil.DQL(Account.class,sql);
    }
}
